/**
 * @ProjectName:Backend
 * @Title: CustomizationException
 * @Package com.phrp.exception
 * @Description: 自定义异常类：获取错误码和错误信息；以及利用构造方法实例化异常处理类，并设置错误码和错误信息
 * @author SuShuChao
 * @date 2024/4/17 13:47
 * @version V1.0
 * Copyright (c) 2024, 2034279227@qq.com All Rights Reserved.
 */
package com.phrp.exception;

import com.phrp.util.returnResult.ReturnInfoEnum;

public class CustomizationException extends RuntimeException{
    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public CustomizationException() {
        super();
    }

    public CustomizationException(BaseErrorInfoInterface errorInfoInterface) {
        super(errorInfoInterface.getResultCode());
        this.errorCode = errorInfoInterface.getResultCode();
        this.errorMsg = errorInfoInterface.getResultMsg();
    }

    public CustomizationException(BaseErrorInfoInterface errorInfoInterface, Throwable cause) {
        super(errorInfoInterface.getResultCode(), cause);
        this.errorCode = errorInfoInterface.getResultCode();
        this.errorMsg = errorInfoInterface.getResultMsg();
    }

    public CustomizationException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public CustomizationException(ReturnInfoEnum returnInfoEnum) {
        super(returnInfoEnum.getResultCode());
        this.errorMsg = returnInfoEnum.getResultMsg();
        this.errorCode = returnInfoEnum.getResultCode();
    }

    public CustomizationException(ReturnInfoEnum returnInfoEnum, Throwable cause) {
        super(returnInfoEnum.getResultCode(), cause);
        this.errorCode = returnInfoEnum.getResultCode();
        this.errorMsg = returnInfoEnum.getResultMsg();;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
